package com.example.coupon.filter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.ZoneOffset;

/**
 *
 * 在过滤器中存储客户端中的请求时间戳
 * @author wangbo
 * @description:
 * @date 2021/1/2916:36
 */
@Component
@Slf4j
public class PreRequestFilter extends AbstractPreZuulFilter{

    @Override
    protected Object cRun() {
        context.set("startTime", LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli());
        return success();
    }

    @Override
    public int filterOrder() {
        return 0;
    }
}
